<?php
//PingBuWang.Com
//Copyright (c) 2017~2099 http://www.pingbuwang.com All rights reserved.
namespace app\setting\controller;
use think\Request;
use mip\Htmlp;
use mip\AdminApiBase;
class ApiAdminAccessKey extends AdminApiBase
{
    protected $beforeActionList = ['start'];
    public function start() {

    }

    public function accessKeyList()
    {
        $list = db('accessKey')->select();
        return jsonSuccess('获取AccessKey 列表成功',['list' => $list]);
    }

    public function save(){

        $id = input('post.id');
        $name = input('post.name');
        $type = input('post.type');
        $key= input('post.key');
        $saveStatus= input('post.saveStatus');

        $arr= ['name' => $name,'type' => $type,'key' => $key];

        if($saveStatus == 'add'){
            db('accessKey')->insert($arr);
        }else{
            db('accessKey')->where('id',$id)-> update($arr);
        }

        return jsonSuccess('菜单项保存成功');

    }

    public function del(){
        $id = input('post.id');

        db('accessKey')->where('id',$id)->delete();

        return jsonSuccess('菜单项删除成功');
    }

}